package cn.strive.eams.bus.controller;

import cn.strive.eams.base.response.JsonResult;
import cn.strive.eams.bus.pojo.dto.BusQuery;
import cn.strive.eams.bus.pojo.dto.BusSaveParam;
import cn.strive.eams.bus.pojo.vo.BusVO;
import cn.strive.eams.bus.service.BusService;
import cn.strive.eams.virtual.pojo.dto.VirtualQuery;
import cn.strive.eams.virtual.pojo.dto.VirtualSaveParam;
import cn.strive.eams.virtual.pojo.vo.VirtualVO;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/v1/bus")
public class BusController {
    @Autowired
    BusService busService;

    @GetMapping("/select")
    public JsonResult selectBus(BusQuery busQuery){
        log.debug("查询校车:busQuery={}",busQuery);
        List<BusVO> list = busService.selectBus(busQuery);
        return JsonResult.ok(list);
    }



    @PostMapping("/save")
    public JsonResult saveBus(BusSaveParam busSaveParam){
        log.debug("保存校车:busSaveParam={}",busSaveParam);
        busService.saveBus(busSaveParam);
        return JsonResult.ok();
    }

    @PutMapping("/update/status/{id}/{status}")
    @ApiOperation(value = "更新校车状态")
    public JsonResult updateStatus(@PathVariable Long id, @PathVariable String status){
        log.info("更新校车状态:id={},status={}", id, status);
        busService.updateStatus(id, status);
        return JsonResult.ok();
    }

    @PostMapping("/delete/{id}")
    public JsonResult deleteBus(@PathVariable Long id){
        log.debug("删除校车:id={}",id);
        busService.deleteVirtual(id);
        return JsonResult.ok();
    }
    @PostMapping("/delete/batch/{ids}")
    @ApiOperation(value = "批量删除校车")
    public JsonResult deleteBatch(@PathVariable List<Long> ids){
        log.info("批量删除校车信息:ids={}", ids);
        busService.deleteBatch(ids);
        return JsonResult.ok();
    }

}
